package com.itheima.advice;


import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.After;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.springframework.stereotype.Component;

@Component
@Aspect
public class MyAspect {
    @Around("execution(* com.itheima.service.impl.*.*(..))")
    public Object totalTime(ProceedingJoinPoint pjp) throws Throwable {

        long t1 = System.currentTimeMillis();
        Object o = pjp.proceed();
        long t2 = System.currentTimeMillis();
        long t3 = t2 - t1;
        System.out.println(pjp.getSignature().getDeclaringTypeName()+"类中的"+pjp.getSignature().getName()+"方法耗时"+t3+"毫秒-----------");
        return o;
    }


    @After("@annotation(com.itheima.anno.MyBj)")
    public void after2(JoinPoint jp) throws Throwable {

        System.out.println("自定义注解");

    }


}
